import { defineEventHandler } from "h3"
import { UserService } from "../../../services/userService"

export default defineEventHandler(async (event) => {
  const user = event.context.user
  const { totalPoints } = await UserService.getUserPoints(user.id)
  const isProUser = await UserService.isProUser(user.id)

  return {
    id: user.id,
    email: user.email,
    name: user.name,
    avatar: user.avatar,
    totalPoints,
    isPro: isProUser,
    createdAt: user.createdAt,
  }
})
